import React, { Component } from 'react'
import Fasong from '../util/events'
// import {withRouter} from 'react-router-dom' // withRouter 让没有路由功能得组件拥有路由功能
import WithRouter from '../util/withRouter'
class Rights extends Component {
      state={
          selIndex:0,
      }
      componentDidMount(){
          Fasong.addListener('zhao',this.jieshou)
      }
      jieshou=(data)=>{
          this.setState({
              selIndex:data
          })
      }
      changeXq(item){
        this.props.routProps.history.push({
            pathname:"/detail",
               item
       })
       
      }
    
  render() {
    console.log(this.props,11111);
    let {send}=this.props
    let {selIndex}=this.state
    return (
      <div className='rights'>
        {
            send&&send.length?send[selIndex].children.map((item,index)=>{
                return <div key={index}  className='con'>
                    <img src={item.img} alt="" onClick={this.changeXq.bind(this,item)}/>
                   <div>
                   <h4>{item.title}</h4>
                     <p>￥{item.price}</p>
                     <span>+</span>
                   </div>
                </div>
            }):''
        }
      </div>
    )
  }
}

export default WithRouter(Rights)
